package com.xx.servlet.model;

import com.xx.service.BookService;
import com.xx.service.impl.BookServiceImpl;
import com.xx.servlet.base.ViewBaseServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


//只需要处理访问首页请求
public class PortalServlet extends ViewBaseServlet {

    private BookService bookService = new BookServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List books = bookService.selectBooks();
        req.setAttribute("books",books);
        processTemplate("index",req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
